<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2020/4/9 0009
 * Time: 09:37
 */

namespace app\home\controller\report;
use app\home\controller\Base;
use app\home\model\dealer\Dealer;
use app\home\model\order\GoodsOrder;
use app\home\model\order\GoodsOrderDes;
use app\home\model\report\Detection;
use app\home\model\report\ReportGoods;
use app\home\service\CodeService;
use app\home\service\ReportService;
use think\Loader;

class Report extends Base
{
    protected $param=[];
    public function __construct()
    {
        $this->param = input('post.');
    }

    /**列表
     * @return array
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function ler_list(){
        $page       = input("page");
        $list_row   = input("list_row");
        $page       = !empty($page)?$page:1;
        $list_row   = !empty($list_row)?$list_row:5;
        $items_cate = input('items_cate');
        $search     = input('search');
        $field      = input('field');    //T=创建时间 B=购买数量
        $field      = !empty($field)?$field:"ALL";
        $items_cate = !empty($items_cate)?$items_cate:"ALL";
        if(!$items_cate) return CodeService::DETECTION_CATE;
            $Detection = new Detection();
            $where = [];
        if($items_cate != "ALL"){
            $where["items_cate"]=$items_cate;
        }
        if(!empty($search)){
            $where['title']=["like","$search%"];
        }
            $Detection->order="sort asc,create_time desc";
        if($field != "ALL"){
            if($field == "T"){
                $Detection->order="create_time desc";
            }else
                if($field == "B"){
                $Detection->order="buy_count desc";
            }
        }
        $Detection->page=$page;
        $Detection->pageNum=$list_row;
        $Detection->field=['d_id','title','describe','img_plot','is_pay','buy_count','price_original'];

        $rel=$Detection->getPageList($where);
        return CodeService::response(200,CodeService::SUCCESS,$rel);
    }



}